from utils.base_model import BaseModel
from django.db import models


class DeptModel(BaseModel):
    """
    部门模型
    """
    name = models.CharField(verbose_name="部门名称", max_length=50, unique=True)
    address = models.CharField(verbose_name="部门名称", max_length=256, blank=True, null=True, )
    parent = models.ForeignKey('self', verbose_name="部门所在的父部门", null=True, blank=True, related_name="children",
                               on_delete=models.CASCADE)

    def __str__(self):
        return self.name

    class Meta:
        db_table = "t_dept"
        verbose_name = "部门"
        verbose_name_plural = verbose_name
        ordering = ['id']
